package com.pets.springboot_petshop.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author wxk
 * @CreateTime 2024-10-09 09:42:10
 * @Remark 结果类
 * @Version 1.0
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Result <T>{
    private Integer code;//状态码 200-成功 其他-失败
    private String message;//返回响应信息
    private T data;//返回数据
    public boolean isSuccess() {
        return this.code == 200;
    }
    public static <E> Result <E>success(E data){
        return new Result(200,"操作成功",data);
    }
    public static Result success(){
        return new Result(200,"操作成功",null);
    }
    public static Result error(String message){
        return new Result(400, message, null);
    }
}